{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use this script to merge existing and new readings json file when we have a new dataset "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "import argparse\n",
    "\n",
    "from constants import RANGE_KEY, READING_KEY\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('/home/$USER/test_images/true_readings_old.json', 'r') as file:\n",
    "    old_dict = json.load(file)\n",
    "\n",
    "with open('/home/$USER/test_images/true_readings.json', 'r') as file:\n",
    "    new_dict = json.load(file)\n",
    "\n",
    "for key in old_dict:\n",
    "    new_dict[key][READING_KEY] = old_dict[key][READING_KEY] \n",
    "    new_dict[key][RANGE_KEY] = old_dict[key][RANGE_KEY] \n",
    "\n",
    "new_json = json.dumps(new_dict, indent=4)\n",
    "with open('/home/$USER/test_images/true_readings.json', \"w\") as outfile:\n",
    "    outfile.write(new_json)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
